package com.edgclub.edg.uc;

import android.app.Dialog;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.WindowManager;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.edgclub.edg.R;

/**
 * 支付方式选择对话框
 * 
 */
public class PaySelectDialog extends Dialog {

	private ImageView close;
	private TextView tv_wallet;

	private Context context;

	private Dialog dialog;

	private PaySelectDialog instance;

	private RelativeLayout ll_wallet,ll_alipay,ll_weixin;


	public static PaySelectDialog create(Context context, boolean hasCancle) {
		PaySelectDialog instance = new PaySelectDialog(context, hasCancle);
		return instance;

	}

	private PaySelectDialog(Context context, boolean hasCancle) {
		super(context, R.style.MyAlertDialog);
		init(context, hasCancle);
	}

	private void init(Context context, boolean hasCancle) {
		this.context = context;
		WindowManager.LayoutParams lp = new WindowManager.LayoutParams();
		lp.width = context.getResources().getDisplayMetrics().widthPixels;

		View contentView = LayoutInflater.from(context).inflate(
				R.layout.layout_pay_select_dialog, null);

		setContentView(contentView, lp);
		ll_wallet = (RelativeLayout) contentView.findViewById(R.id.ll_wallet);
		ll_alipay = (RelativeLayout) contentView.findViewById(R.id.ll_alipay);
		ll_weixin = (RelativeLayout) contentView.findViewById(R.id.ll_weixin);
		close = (ImageView) contentView.findViewById(R.id.close);
		tv_wallet = (TextView) contentView.findViewById(R.id.tv_wallet);

		close.setOnClickListener(new View.OnClickListener() {
			@Override
			public void onClick(View view) {
				dismiss();
			}
		});
	}


	public TextView getTv_wallet() {
		return tv_wallet;
	}

	public void setTv_wallet(TextView tv_wallet) {
		this.tv_wallet = tv_wallet;
	}


	/**
	 * 设置银联的监听
	 */
	public void setWalletListener(
			final WalletClickListener onWalletClickListener) {
		ll_wallet.setOnClickListener(new View.OnClickListener() {

			@Override
			public void onClick(View view) {
				if (null != onWalletClickListener) {
					onWalletClickListener.walletClick();
				}
			}
		});
	}

	/**
	 * 设置支付宝的监听
	 */
	public void setAlipayClickListener(
			final AlipayClickListener onAlipayClickListener) {
		ll_alipay.setOnClickListener(new View.OnClickListener() {

			@Override
			public void onClick(View view) {
				if (null != onAlipayClickListener) {
					onAlipayClickListener.alipayClick();
				}
			}
		});
	}
	/**
	 * 设置支付宝的监听
	 */
	public void setWeixinClickListener(
			final WeixinClickListener onWeixinClickListener) {
		ll_weixin.setOnClickListener(new View.OnClickListener() {

			@Override
			public void onClick(View view) {
				if (null != onWeixinClickListener) {
					onWeixinClickListener.weixinClick();
				}
			}
		});
	}

	public interface WalletClickListener {
		public void walletClick();
	}

	public interface AlipayClickListener {
		public void alipayClick();
	}
	public interface WeixinClickListener {
		public void weixinClick();
	}


	

}
